package com.crazy.practice.boot.listener;

import com.crazy.practice.boot.even.PropertiesChangeEven;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author panyonghui
 * @describe 配置变更事件监听器
 * @date 2023/4/13 15:59
 */
@Slf4j
@Component
public class PropertiesChangeListener2 {

    @EventListener(PropertiesChangeEven.class)
    public void propertiesListener(PropertiesChangeEven propertiesChangeEven){
        log.info("通过实现@EventListener注解监听配置变更");

        log.info("变更配置:{}", propertiesChangeEven.getSource());
        log.info("旧配置:{}", propertiesChangeEven.getOldProperties());
        log.info("新配置:{}", propertiesChangeEven.getNewProperties());
    }
}
